The present invention relates to software execution machines. More particularly, the invention relates to a method and a device to improve execution of method invocations and returns.
As is known, object oriented programming involves three major concepts: encapsulation, inheritance, and polymorphism. Classes are software modules and contain data (e.g., data members) and processing functions that manipulate that data (e.g., methods (hereinafter “Methods”)). Encapsulation involves making the internal details of the data and Methods used inaccessible (by language access restrictions) to other classes and providing an official interface for accessing the class. Thus, some Methods and data are visible externally to the class, and others are hidden. Objects are instances of a class. Every object of the same class has exactly the same data layout, though the contents of the data may vary between objects. Methods can act on data defined or initialized within the object or they may also receive data through parameter passing. A Method is executed by using its name in a process often referred to as an invocation or invoke. Methods may provide result or output data using a return statement. Inheritance allows Methods and data in one class, that are part of the official interface to that class, to be automatically available to sub-classes without any need for the sub-class to define them further. The subclass is free to add its own features and also override inherited Methods with its own Methods to specialize that behavior for its own class. For example, a class “MultiMediaPlayer” may define a Method “Play” which is made part of its official interface. Another Method in this class invokes “Play,” using a MultiMediaPlayer object. There may be two subclasses, a VideoPlayer class and an AudioPlayer class, that inherit “Play” from “MultiMediaPlayer” but choose to override it with their own Method, appropriately redefined to reflect the differences in video player and audio player playback. When an object of type VideoPlayer is used in MultiMediaPlayer's invoke on “Play,” this results in VideoPlayer's “Play” Method receiving control. Similarly, when an object type AudioPlayer is used in MultiMediaPlayer's invoke on “Play,” this results in AudioPlayer “Play” Method receiving control. The MultiMediaPlayer's invoke exhibits polymorphism, as different object shapes can be used with it (so long as they are correctly related by class hierarchy).
Java is one type of object-oriented language and is often implemented as an interpreted language. One feature of Java is that the overall process of executing Java source code involves a conversion of the Java source code into an intermediate form called bytecode. (This process may be carried out by a Java compiler). Bytecode is executed by an interpreter in a Java virtual machine. In simple terms, the Java virtual machine is so named because while it performs bytecode processor or machine functions (i.e., execution of bytecode instructions) it most commonly consists of software (often written in the C programming language) rather than hardware. Thus, it is a virtual implementation of a bytecode processor or machine. There are also Java hardware accelerators (actual hardware) capable of directly executing some of the bytecodes. Ultimately, an actual hardware processor or combination of hardware processor and Java hardware accelerator executes the virtual machine.
The semantics of bytecode are specified by the Java Virtual Machine (“JVM”) specification (available from Sun Microsystems and other publishers). Bytecode was originally designed to execute on a stack-based abstraction of a computer processor, i.e., a virtual machine. As noted above, a virtual machine may be implemented through pure software, or a combination of software and hardware. When a Java virtual machine is implemented with software and hardware, the hardware component is referred to as a Java hardware accelerator. The accelerator can exist as a separate coprocessor, or as an extension to the core of existing processor architecture. However, Java Method invocations and returns are typically handled by software, regardless of the presence of a hardware accelerator. The complex semantics of invocations and returns may require several lines of C code, which in turn amounts to roughly 100–150 machine instructions for invokes and about 50–60 machine instructions for returns.
There is a growing demand for Java applications for devices (such as cell phones, PDA's, and the like) having relatively limited processing power, limited memory, or both. However, the limited capabilities of these devices make it difficult to execute all but the shortest and simplest Java programs. And, even where execution is possible, the speed of execution is often unacceptably slow.